mod

 

number1 mod number2

The primitive mod completes the modulo operation, which takes two numbers, divides them, and returns the remainder, where the remainder of (number1 / number2) is the value reported. For example, show 17 mod 4 would report 1, because 17 divided by 4 has a quotient of 4 and a remainder of 1. Show 9 mod 3 would report 0, because 9 divided by 3 leaves a remainder of 0.

 

Try it Yourself

 
 
 
 
 
 
 

What's next?

Once you mastered the mod primitive, don't stop there. Check out the resources below to improve your NetLogo skills.

 
Published NetLogo models that use the mod primitive:
 
 
Similar primitives:
mean

Find the mean of a list of values.

Read more
count

Count the number of agents in an agentset.

Read more
if

Conditionally run a command.

Read more
 
Learn another primitive